/*
 *  This class is part of WorkTimeCalculator Android App
 *  Author: Domenico Pio Novelli
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.dpndeveloper.wtc;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;

import com.dpndeveloper.wtc.adapter.TabSwipeAdapter;

/**
 * <p>
 * Day History Activity: activity to show/manage history by day, week and month
 * <p>
 * 
 * @author Domenico Pio Novelli
 * 
 */
public class WtcHistoryActivity extends TabActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		View view = getLayoutInflater().inflate(R.layout.history_layout, null);

		setContentView(view);

		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = getTabHost(); // The activity TabHost
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, WtcDayHistoryActivity.class);

		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost
				.newTabSpec("day")
				.setIndicator(getResources().getString(R.string.by_day),
						res.getDrawable(R.drawable.ic_action_search))
				.setContent(intent);
		tabHost.addTab(spec);

		// Do the same for the other tabs
		intent = new Intent().setClass(this, WtcWeekHistoryActivity.class);
		spec = tabHost
				.newTabSpec("week")
				.setIndicator(getResources().getString(R.string.by_week),
						res.getDrawable(R.drawable.ic_action_search))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, WtcMonthHistoryActivity.class);
		spec = tabHost
				.newTabSpec("month")
				.setIndicator(getResources().getString(R.string.by_month),
						res.getDrawable(R.drawable.ic_action_search))
				.setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTab(0);

		view.setOnTouchListener(new TabSwipeAdapter(tabHost));
	}

}
